package com.zkadmin.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

@Entity
@Table(name = "sys_menu")
public class SysMenu extends AuditorAndVersionEntity {
	private static final long serialVersionUID = 1216671153222373700L;
	@Column(unique = true, nullable = false, length = 50)
	private String name;
	@Column(unique = true, nullable = false, length = 12)
	private String code;
	private String url = "";
	@Column(nullable = false, length = 50)
	private String icon = "z-icon-file-text-o";
	private int sort = 0;
	@Column(name = "is_open")
	private boolean isOpen;

	@ManyToMany(cascade = CascadeType.REFRESH, mappedBy = "menus")
	private Set<SysRole> roles = new HashSet<SysRole>();

	public SysMenu() {

	}

	public SysMenu(String name, String code, String url, String icon, int sort) {
		this(name, code, url, icon, sort, false);
	}

	public SysMenu(String name, String code, String url, String icon, int sort, boolean isOpen) {
		this.name = name;
		this.code = code;
		this.url = url;
		this.icon = icon;
		this.sort = sort;
		this.isOpen = isOpen;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public int getSort() {
		return sort;
	}

	public void setSort(int sort) {
		this.sort = sort;
	}

	public Set<SysRole> getRoles() {
		return roles;
	}

	public void setRoles(Set<SysRole> roles) {
		this.roles = roles;
	}

	public boolean isOpen() {
		return isOpen;
	}

	public void setOpen(boolean isOpen) {
		this.isOpen = isOpen;
	}

}
